<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员设置</title>
    <script src="/assets/tailwind.js"></script>
    <link href="/assets/fontawesome-free-6.7.2-web/css/all.min.css" rel="stylesheet">
    <script src="/assets/qrcode.min.js"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#4080FF',
                        success: '#00B42A',
                        warning: '#FF7D00',
                        danger: '#F53F3F',
                        dark: '#1D2129',
                        light: '#F2F3F5',
                    },
                    fontFamily: {
                        inter: ['Inter', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .bg-gradient-blue {
                background: linear-gradient(135deg, #165DFF 0%, #4080FF 100%);
            }
            .shadow-card {
                box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            }
            .transition-all-300 {
                transition: all 0.3s ease;
            }
            .tab-active {
                @apply border-primary text-primary;
            }
            .table-row-hover {
                @apply hover:bg-gray-50 transition-all-300;
            }
        }
    </style>
</head>
<body class="bg-gray-50 font-inter text-dark min-h-screen flex flex-col">
    <!-- 顶部导航栏 -->
    <header class="bg-white shadow-sm sticky top-0 z-50">
        <div class="container mx-auto px-4 py-3 flex items-center justify-between">
            <div class="flex items-center space-x-2">
                <i class="fa fa-shield text-primary text-xl"></i>
                <h1 class="text-xl font-bold text-primary">管理员控制台</h1>
            </div>
            <nav class="hidden md:flex items-center space-x-6">
                <a href="." class="text-gray-600 hover:text-primary transition-all-300 flex items-center">
                    <i class="fa fa-tachometer mr-2"></i> 首页
                </a>
                <a href="admin-settings" class="text-primary font-medium flex items-center">
                    <i class="fa fa-user-circle mr-2"></i> 管理员设置
                </a>
            </nav>
            <div class="flex items-center space-x-4">
                <a href="." class="text-gray-600 hover:text-primary transition-all duration-300 inline-block">
                    <i class="fa fa-bell text-xl"></i>
                </a>
                <div class="relative">
                    <button class="flex items-center space-x-2 focus:outline-none" id="adminDropdownBtn">
                        <img src="https://picsum.photos/200/200?random=1" alt="管理员头像" class="w-8 h-8 rounded-full object-cover border-2 border-primary">
                        <span class="hidden md:inline-block font-medium">admin</span>
                        <i class="fa fa-angle-down text-gray-500"></i>
                    </button>
                    <!-- 下拉菜单（使用 Tailwind 类控制样式和交互） -->
                    <ul id="adminDropdownMenu" class="absolute right-0 mt-2 w-48 bg-white shadow-lg rounded-lg py-1 hidden">
                        <li>
                        <a href="admin-settings" 
                            class="block px-4 py-2 text-sm text-gray-700 hover:bg-primary hover:text-white transition-colors">
                            <i class="fa fa-key mr-2"></i> 修改密码
                        </a>
                        </li>
                        <li>
                        <a href="logout" 
                            class="block px-4 py-2 text-sm text-gray-700 hover:bg-primary hover:text-white transition-colors">
                            <i class="fa fa-sign-out-alt mr-2"></i> 登出
                        </a>
                        </li>
                    </ul>
                </div>
                <button class="md:hidden text-gray-600 hover:text-primary transition-all-300">
                    <i class="fa fa-bars text-xl"></i>
                </button>
            </div>
        </div>
    </header>

    <!-- 主要内容区 -->
    <main class="flex-grow container mx-auto px-4 py-8">
        <div class="max-w-5xl mx-auto">
            <!-- 页面标题 -->
            <div class="mb-8">
                <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-dark mb-2">管理员设置</h2>
                <p class="text-gray-500">修改管理员密码</p>
            </div>

            <!-- 管理员设置卡片 -->
            <div class="bg-white rounded-xl shadow-card p-6 mb-8">
                <form id="admin-form" class="space-y-6"  action="/changepassword"  method="POST">
                    <div class="space-y-2">
                        <label for="current_password" class="block text-sm font-medium text-gray-700">旧密码</label>
                        <input type="password" id="current_password" name="current_password" 
                            class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all-300"
                            placeholder="请输入旧密码">
                    </div>
                    <div class="space-y-2">
                        <label for="new_password" class="block text-sm font-medium text-gray-700">密码</label>
                        <input type="password" id="new_password" name="new_password" 
                            class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all-300"
                            placeholder="请输入密码">
                    </div>
                    <div class="space-y-2">
                        <label for="confirm_password" class="block text-sm font-medium text-gray-700">密码</label>
                        <input type="password" id="confirm_password" name="confirm_password" 
                            class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all-300"
                            placeholder="再次输入密码">
                    </div>
                    <div class="flex justify-end">
                        <button id="save-admin-btn" class="px-6 py-3 bg-primary text-white rounded-lg hover:bg-primary/90 transition-all-300 flex items-center shadow-md hover:shadow-lg">
                            保存
                        </button>
                    </div>
                </form>
            </div>

            <div    id="password-change-result" 
                    class="mt-4 flex items-center space-x-3 p-3 rounded-lg transition-all-300 {{ password_result_color }}-100 border {{ password_result_color }}-200 text-{{ password_result_color }}-500"
                >
                    <span id="password-change-text" class="flex-1">
                        {{ password_change_result }}
                    </span>
            </div>
            <!-- 操作结果提示 -->
            <div id="result-message" class="hidden p-4 rounded-lg mb-6 transition-all-300 transform translate-y-4 opacity-0">
                <div id="success-message" class="hidden bg-success/10 border border-success/20 text-success p-4 rounded-lg">
                    <div class="flex items-start">
                        <div class="flex-shrink-0 pt-0.5">
                            <i class="fa fa-check-circle text-xl"></i>
                        </div>
                        <div class="ml-3">
                            <h3 class="text-sm font-medium">操作成功</h3>
                            <div class="mt-2 text-sm">
                                <p id="success-text">操作已成功完成。</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="error-message" class="hidden bg-danger/10 border border-danger/20 text-danger p-4 rounded-lg">
                    <div class="flex items-start">
                        <div class="flex-shrink-0 pt-0.5">
                            <i class="fa fa-exclamation-circle text-xl"></i>
                        </div>
                        <div class="ml-3">
                            <h3 class="text-sm font-medium">操作失败</h3>
                            <div class="mt-2 text-sm">
                                <p id="error-text">操作未能完成，请重试。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- 页脚 -->
    <footer class="bg-white border-t border-gray-200 py-6">
        <div class="container mx-auto px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <p class="text-gray-500 text-sm">&copy; 2025 北京椰子树信息技术有限公司. 保留所有权利.</p>
                </div>
                <div class="flex space-x-6">
                    <a href="http://www.coconet.cn" class="text-gray-500 hover:text-primary transition-all-300">
                        <i class="fa fa-question-circle mr-1"></i> 帮助中心
                    </a>
                    <a href="http://www.coconet.cn" class="text-gray-500 hover:text-primary transition-all-300">
                        <i class="fa fa-file-text-o mr-1"></i> 隐私政策
                    </a>
                    <a href="mailto:goodput3@qq.com" class="text-gray-500 hover:text-primary transition-all-300">
                        <i class="fa fa-phone mr-1"></i> 联系我们
                    </a>
                </div>
            </div>
        </div>
    </footer>
    <script>
        const dropdownBtn = document.getElementById('adminDropdownBtn');
        const dropdownMenu = document.getElementById('adminDropdownMenu');
      
        // 切换菜单显示状态
        dropdownBtn.addEventListener('click', () => {
          dropdownMenu.classList.toggle('hidden');
          // 切换箭头旋转动画（可选）
          dropdownBtn.querySelector('.fa-angle-down').classList.toggle('rotate-180');
        });
      
        // 点击外部关闭菜单
        window.addEventListener('click', (event) => {
          if (!event.target.closest('#adminDropdownBtn, #adminDropdownMenu')) {
            dropdownMenu.classList.add('hidden');
            dropdownBtn.querySelector('.fa-angle-down').classList.remove('rotate-180');
          }
        });
    </script>
</body>
</html>
